package org.csmzxy.class2333;

class YieldTread extends Thread{
    public YieldTread(String name){
        super(name);
    }

    @Override
    public void run() {
        for (int i = 1; i < 4;i++){
            String threadName = Thread.currentThread().getName();
            if (i==2){
                System.out.println(threadName+"线程起步！");
                Thread.yield();
            }
            System.out.println(threadName+"---"+i);
        }
    }
}
public class Example05 {
    public static void main(String[] args){
        Thread thread1 = new YieldTread("thread1");
        Thread thread2  = new YieldTread("thread2");
        thread1.start();
        thread2.start();
    }
}
